#!/bin/bash
# soon, #!/usr/local/bin/swamp_client.py --


# switch between local and swamp path roots.
if [ $SHELL = "swamp" ] ; then 
  USERROOT=/esmf/mtosca
else
  USERROOT=/data/mtosca
fi

CASEID=control_sst9605x5
CASEPATH="$USERROOT/$CASEID"

# This is the long, simple way of iterating over 12 months
# for month in 01 02 03 04 05 06 07 08 09 10 11 12 ; do

# Perhaps this is shorter to type?
for monthn in `seq 1 12` ; do
  month=`printf "%02d" ${monthn}`
  # create monthly time series
  ncrcat ${CASEPATH}/${CASEID}.cam2.h0.*-${month}.nc ${CASEID}.${month}.series.nc
  # compute monthly averages
  ncwa ${CASEID}.${month}.series.nc ${CASEID}.${month}.avg.nc
done

# only .avg.nc files will be returned (.series.nc will be assumed as 'temporary')


# The following are available pre-defined variables that you can
# reference in your scripts.
# SWAMPVERSION : "0.1+" -- version number, perhaps useful in the future.
# SWAMPHOSTNAME" : <hostname> -- the hostname for the swamp service,
#                  probably a fully-qualified domain name (FQDN).
# SHELL : "swamp" -- This is always set to "swamp" in the SWAMP environment

